import logging

from xinan_ui.proxy.base_page import PageHandle
from xinan_ui.tools.read_yml_xn import ReadYaml

PTZH=data_eles=ReadYaml('../config/xnapp.yml').read_yaml()['普通账户登录页']
class AccountLogin(PageHandle):
    def __init__(self,driver):
        self.driver=driver
        super().__init__(self.driver)

    def account_login(self,account_num,password):
        logging.info('开始进行普通账户登录')
        self.click_button(PTZH[0]['设备权限提示框'])
        try:
            self.click_button(PTZH[1]['允许语音电话提示框'][0])
        except:
            self.click_button(PTZH[1]['允许语音电话提示框'][1])

        self.input_element(PTZH[2]['资金账号输入框'],account_num)

        self.input_element(PTZH[3]['密码输入框'], password)

        self.click_button(PTZH[4]['交易登录按钮'])
        try:
            self.click_button(PTZH[5]['指纹提示弹窗'])
        except:
            print('该版本没有指纹登录提示')
            logging.info('该版本没有指纹登录提示')
        try:
            self.click_button(PTZH[6]['风险测评失效弹窗'])
        except:
            print('没有出现风险测评')
            logging.info('没有出现风险测评')

        logging.info('进入普通交易界面')